<template>
    <view class="home">
        <uni-forms
            :model="formData" 
            ref="form" 
            :rules="rules1" 
            validateTrigger="submit" 
            label-width="180rpx"
            err-show-type='none'
        >
           <!-- <view class="box-1">
                <view style="display:flex; justify-content: space-between; align-items: center;">
                    <view class="money-box">
                        <template v-if="formData.zo_ex23 >= 0">
                            <span class="money-span-1">预估￥ </span>
                            <span class="money-span-2">{{formData.zo_ex23 > 0 ? formData.zo_ex23 : '--'}}</span>
                        </template>
                    </view>
                    <button
                        @click="submit1"
                        class="btn-box"
                    >
                        <view style="font-weight: bold;">下一步</view>
                    </button>
                </view>
            </view> -->
            <view class="box-1">
                <uni-section
                    type="line"
                    title="人员信息" 
                    sub-title=""
                >
                </uni-section>
                <uni-forms-item
                    name="zo_ex2"
                    label="被转运人"
                    required
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex2"
                        type="text" 
                        placeholder="请输入被转运人" 
                    />
                </uni-forms-item>
                <uni-forms-item
                    name="zo_ex3"
                    label="性别"
                    required
                >
                    <view class="checkbox-box">
                        <uni-data-checkbox
                            v-model="formData.zo_ex3" 
                            :localdata="zo_ex3Range" 
                        ></uni-data-checkbox>
                    </view>
                </uni-forms-item>
                <uni-forms-item
                    name="zo_ex4"
                    label="年龄"
                    required
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex4"
                        type="digit" 
                        placeholder="请输入年龄" 
                    />
                </uni-forms-item>
                <uni-forms-item
                    name="zo_ex6"
                    label="联系人"
                    required
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex6"
                        type="text" 
                        placeholder="请输入联系人" 
                    />
                </uni-forms-item>
                <uni-forms-item
                    name="zo_ex7"
                    label="联系电话"
                    required
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex7"
                        maxlength="11"
                        type="digit" 
                        placeholder="请输入联系电话" 
                    />
                </uni-forms-item>
            </view>
            
            <view
                class="box-1"
            >
                <uni-section
                    type="line"
                    title="其他信息" 
                    sub-title=""
                >
                </uni-section>
                <uni-forms-item
                    v-if="formData.zo_ex73 == '否'"
                    name="zo_ex74"
                    label="是否吸氧"
                >
                    <view class="checkbox-box">
                        <uni-data-checkbox
                            v-model="formData.zo_ex74" 
                            :localdata="zo_ex74Range" 
                            @change="getMoney"
                        ></uni-data-checkbox>
                    </view>
                </uni-forms-item>
                <uni-forms-item
                    v-if="formData.zo_ex73 == '否'"
                    name="zo_ex49"
                    label="是否抬楼"
                >
                    <view class="checkbox-box">
                        <uni-data-checkbox
                            v-model="formData.zo_ex49" 
                            :localdata="zo_ex74Range" 
                        ></uni-data-checkbox>
                    </view>
                </uni-forms-item>
                <!-- <template
                    v-if="formData.zo_ex73 == '否'"
                    >
                    <uni-forms-item
                        label-width="280rpx"
                        name="zo_ex76"
                        label="是否医护人员陪同"
                    >
                        <view class="checkbox-box">
                            <uni-data-checkbox
                                v-model="formData.zo_ex76" 
                                :localdata="zo_ex74Range" 
                            ></uni-data-checkbox>
                        </view>
                    </uni-forms-item>
                    <view class="" style="font-size: 20rpx; padding: 0 0 30rpx 0; color: red;">
                        *具有专业资质医护人员陪同需要提前一天预约
                    </view>
                </template> -->
                <uni-forms-item
                    v-if="formData.zo_ex73 == '否'"
                    name="zo_ex21"
                    label="惠民权益"
                >
                    <uni-data-select
                        :disabled="formData.zo_ex82!=''"
                        v-model="formData.zo_ex21"
                        :localdata="zo_ex21Range"
                        placeholder="请选择惠民权益"
                        emptyTips="暂无惠民权益"
                        class="my-data-select-1"
                        @change="zo_ex21Change"
                    ></uni-data-select>
                </uni-forms-item>
                <template v-if="formData.zo_ex21 == '现（退）役军人（含家属）、三属人员八一折扣优待礼遇'">
                    <myFilePicker
                        name="imageValue1"
                        label="相关证件"
                        uploadModel="转运编辑"
                        uploadName="惠民证明材料"
                        uploadtype="惠民证明材料"
                        v-model="formData.imageValue1"
                        v-model:f_id="formData.f_id"
                        :required="formData.zo_ex21 ? true : false"
                    />
                    <view style="color: red; font-size: 20rpx;box-sizing: border-box;padding-left: 180rpx;padding-bottom: 20rpx;">
                        *若您符合相关惠民权益,请上传惠民相关证件(如优待证，退伍证)
                    </view>
                </template>
                <template v-if="formData.zo_ex21 == '杭州联合银行贵宾权益'">
                    <uni-forms-item
                        name="zo_ex78"
                        label="兑换码"
                        required
                    >
                        <uni-easyinput 
                            v-model="formData.zo_ex78"
                            type="text" 
                            placeholder="请输入兑换码" 
                            @change="getMoney"
                        />
                    </uni-forms-item>
                </template>
                <uni-forms-item
                    v-if="formData.zo_ex73 == '否'"
                    name="zo_ex82"
                    label="优惠券"
                >
                    <uni-data-select
                        :disabled="formData.zo_ex21!=''"
                        v-model="formData.zo_ex82"
                        :localdata="zo_ex82Range"
                        placeholder="请选择优惠券"
                        emptyTips="暂无优惠券"
                        class="my-data-select-1"
                        @change="zo_ex82Change"
                    ></uni-data-select>
                </uni-forms-item>
                <view 
                    v-if="formData.zo_ex73 == '否'"
                    style="color: red; font-size: 20rpx;box-sizing: border-box;padding-left: 180rpx;padding-bottom: 20rpx;"
                >
                    *优惠券和惠民权益最多选择一项优惠折扣
                </view>
                <!-- <uni-forms-item
                    v-if="formData.zo_ex76 == '是'"
                    name="zo_ex1001"
                    label="病情描述"
                    required
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex1001"
                        type="textarea" 
                        autoHeight
                        maxlength="100"
                        placeholder="请输入病情描述" 
                    />
                </uni-forms-item> -->
                <uni-forms-item
                    name="zo_ex40"
                    label="客户留言"
                >
                    <uni-easyinput 
                        v-model="formData.zo_ex40"
                        type="textarea" 
                        autoHeight
                        maxlength="100"
                        placeholder="请输入客户留言" 
                    />
                </uni-forms-item>
            </view>
            <view
                v-if="formData.zo_ex73 == '否'"
                class="box-1"
            >
                <view style="display: flex; justify-content: flex-end;">
                    预估费用：<view style="width: 160rpx; font-weight: bold; color: red;">{{Number(formData.zo_ex23).toFixed(2)}}<text style="font-weight: 500;">元</text></view>
                </view>
            </view>
            <button
                :disabled="isDisabledConfirm"
                @click="showPopup1"
                style=""
                :class="[ isDisabledConfirm ? 'disabled-btn' : 'default-btn']"
            >
                <view style="font-weight: bold;">确认</view>
            </button>
            
         </uni-forms>
         <uni-popup
             ref="popup1" 
             type="center"
             :is-mask-click="false"
         >
            <view class="my-popup-box">
                <view class="my-popup-box-img">
                    <view class="my-popup-box-img-text">预估费用明细</view>
                </view>
                <view class="my-popup-box-content">
                    <view class="my-popup-box-content-text-1">起点：{{formData.zo_ex41}}</view>
                    <view 
                        v-if="formData.zo_tjd_n_1" 
                        class="my-popup-box-content-text-1"
                    >
                        途经点：{{formData.zo_tjd_n_1}}
                    </view>
                    <view v-if="formData.zo_tjd_n_2" 
                        class="my-popup-box-content-text-1"
                    >
                        途经点：{{formData.zo_tjd_n_2}}
                    </view>
                    <view 
                        v-if="formData.zo_tjd_n_3" 
                        class="my-popup-box-content-text-1"
                    >
                        途经点：{{formData.zo_tjd_n_3}}
                    </view>
                    <view class="my-popup-box-content-text-1">终点：{{formData.zo_ex42}}</view>
                    <view class="my-popup-box-content-text-1">里程数：{{ Number(formData.zo_ex20).toFixed(2) }}km</view>
                    <view  style="border-bottom: 1rpx solid #d8c7c7; margin-bottom: 10rpx"></view>
                   
                    <view class="my-popup-box-content-text-1">起步价：<text>￥{{ Number(formData.zo_ex79).toFixed(2) }}元</text></view>
                    <view class="my-popup-box-content-text-1">里程费：<text>￥{{ Number(formData.zo_ex80).toFixed(2) }}元</text></view>
                    <view class="my-popup-box-content-text-1">过路费：<text>￥{{ Number(formData.zo_ex46).toFixed(2) }}元</text></view>
                    <view class="my-popup-box-content-text-1">吸氧费用：<text>￥{{ Number(formData.zo_ex55).toFixed(2) }}元</text></view>
                    <view class="my-popup-box-content-text-1">其他费用：<text>￥{{ Number(formData.zo_ex81).toFixed(2) }}元</text></view>
                    <view  style="border-bottom: 1rpx solid #d8c7c7; margin-bottom: 10rpx"></view>
                    <view class="my-popup-box-content-text-1">费用合计：<text>￥{{ (Number(formData.zo_ex23) + Number(formData.zo_ex77)).toFixed(2) }}元</text></view>
                    <template v-if="formData.zo_ex21 || formData.zo_ex82">
                        <view 
                            v-if="formData.zo_ex21" 
                            class="my-popup-box-content-text-1"
                        >
                            惠民权益：{{ formData.zo_ex21 }}
                        </view>
                        <view 
                            v-else-if="formData.zo_ex82" 
                            class="my-popup-box-content-text-1"
                        >
                            优惠券：{{ formData.zo_ex82 }}
                        </view>
                        <view 
                            class="my-popup-box-content-text-1" 
                            style="color: #ce8e1a"
                        >
                            优惠金额：<text>￥-{{ Number(formData.zo_ex77).toFixed(2) }}元</text>
                        </view>
                    </template>
                  
                   <view class="my-popup-box-content-text-1" style="font-size: 30rpx">预估支付：<text style="color: red; font-weight: bold;">￥{{ Number(formData.zo_ex23).toFixed(2) }}元</text></view>
                   <template v-if="formData.zo_ex76 == '是'">
                       <view  style="border-bottom: 1rpx solid #d8c7c7; margin-bottom: 10rpx"></view>
                       <view class="my-popup-box-content-text-1" style="color: red">温馨提示：第三方服务机构医护人员的陪同费用另外收取</view>
                   </template>
                   <!-- <view class="my-popup-box-content-text-1" style="color: red">订单完成后会获得一定积分，可在积分商城进行兑换</view> -->
               </view>
               <view style="display: flex; padding-top: 20rpx; box-sizing: border-box;">
                   <button
                        size="mini"
                        type="warn"
                        style=""
                        @click="popup1.close()"
                   >
                       取消
                   </button>
                   <button
                        size="mini"
                        style="background: #2979ff; color: #fff; "
                        @click="popup1.close();submit1()"
                   >
                       确认
                   </button>
               </view>
            </view>
          </uni-popup>
          <uni-popup
              ref="popup2" 
              type="center"
              :is-mask-click="false"
          >
              <view class="my-popup-box">
                  <view class="my-popup-box-img">
                      <view class="my-popup-box-img-text">温馨提示</view>
                  </view>
                  <view class="my-popup-box-content">
                      <view class="my-popup-box-content-text-1" style="color: red">温馨提示：晚17点30分至次日早08点30分紧急转运请致电人工客服：4008897120。</view>
                  </view>
                  <view style="display: flex; padding-top: 20rpx; box-sizing: border-box;">
                      <button
                          size="mini"
                          type="warn"
                          style=""
                          @click="popup2.close();redirectToTransferOrder()"
                      >
                          取消
                      </button>
                      <button
                          size="mini"
                          style="background: #2979ff; color: #fff; "
                          @click="callPhone()"
                      >
                          联系人工
                      </button>
                  </view>
              </view>
          </uni-popup>
    </view>
</template>

<script lang="ts" setup>
    import { onLoad, onShow, onHide, onReady, onUnload, onTabItemTap } from '@dcloudio/uni-app'
    import { markRaw, onBeforeUnmount, reactive, ref, onMounted, watchEffect, watch } from 'vue'
    import type { Ref, Raw } from 'vue'
    import { getCityApi, getPlaceRetrievalApi, countkilometreApi, countmoneyApi, appSaveOrderApi, preferentialListApi, getAreaApi, getCouponCodeListApi, getWechatMiniParamApi } from '@/apis/index'
    import { isPhone, getDateTime, qqMapTransBMap, getDaysDiff, dateformatter } from '@/utils/utils'
    import uploadApi from '@/apis/uploadApi'
    import myFilesPicker from '@/components/myFilesPicker/myFilesPicker.vue'
    import myFilePicker from '@/components/myFilePicker/myFilePicker.vue'
    
    const popup1: Ref<any> = ref(null)
    const popup2: Ref<any> = ref(null)
    const zo_ex3Range: Raw<any[]> = markRaw([
        { value: '男', text: '男' },
        { value: '女', text: '女' },
    ])
    const zo_ex74Range: Raw<any[]> = markRaw([
        { value: '是', text: '是' },
        { value: '否', text: '否' },
    ])
    const zo_ex21Range: Ref<any[]> = ref([
        // {
        //     text: '现（退）役军人（含家属）、三属人员八一折扣优待礼遇',
        //     value: '现（退）役军人（含家属）、三属人员八一折扣优待礼遇'
        // },
        // {
        //     text: '三属人员八一折扣优待礼遇',
        //     value: '三属人员八一折扣优待礼遇'
        // },
    ])
    const zo_ex82Range: Ref<any[]> = ref([
        
    ])
    
    const formData: Ref<any> = ref({
    })
    const rules1: any = reactive({
        zo_ex2: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入被转运人',
                },
            ],
        },
        zo_ex3: {
            rules: [
                {
                    required: true,
                    errorMessage: '请选择性别',
                },
            ],
        },
        zo_ex4: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入年龄',
                },
            ],
        },
        zo_ex7: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入联系电话',
                },{
                    validateFunction: function(rule, value, data, callback){
                        if (!isPhone(value)) {
                            callback('请输入正确的联系电话')
                        }
                        return true
                    }
                }
            ],
        },
        zo_ex6: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入联系人',
                }
            ],
        },
        // zo_ex76: {
        //     rules: [
        //         {
        //             validateFunction: function(rule, value, data, callback){
        //                 let dat1 = new Date(formData.value.zo_dat1.split(' ')[0])
        //                 let dat2 = new Date(dateformatter(new Date()))
        //                 dat2.setDate(dat2.getDate() + 1);
        //                 if (value == '是' && formData.value.zo_dat1 && (dat1 < dat2)) {
        //                     callback('医护人员陪同需要提前一天预约')
        //                 }
        //                 return true
        //             }
        //         }
        //     ],
        // },
        // zo_ex74: {
        //     rules: [
        //         {
        //             required: true,
        //             errorMessage: '请选择是否吸氧',
        //         },
        //     ],
        // },
        // zo_ex49: {
        //     rules: [
        //         {
        //             required: true,
        //             errorMessage: '请选择是否抬楼',
        //         },
        //     ],
        // },
        imageValue1: {
            rules: [
                {
                    required: true,
                    errorMessage: '请上传优惠相关证件',
                },
                // {
                //     validateFunction: function(rule, value, data, callback){
                //         if (formData.value.zo_ex21 && !value) {
                //             callback('请上传优惠相关证件')
                //         }
                //         return true
                //     }
                // }
            ],
        },
        zo_ex78: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入兑换码',
                },
                // {
                //     validateFunction: function(rule, value, data, callback){
                //         if (formData.value.zo_ex21 == '杭州联合银行贵宾权益' && !value) {
                //             callback('请输入兑换码')
                //         }
                //         return true
                //     }
                // }
            ],
        },
        zo_ex1001: {
            rules: [
                {
                    required: true,
                    errorMessage: '请输入病情描述',
                },
            ],
        },
    })
    const form: Ref<any> = ref(null)
    const isDisabledConfirm: Ref<boolean> = ref(false)
    
    // onTabItemTap((e: any) => {
    //     console.log(e)
    //     uni.setTabBarItem({
    //       index: 0,
    //       text: '',
    //       // pagePath: 'pages/index/index',
    //       // iconPath: 'static/tabBar/home-1.png',
    //       // selectedIconPath: 'static/logo.png'
    //     })
    // })
    // 如果需要使用 validateFunction 自定义校验规则,则不能采用 uni-forms 的 rules 属性来配置校验规则，这时候需要通过ref，在onReady生命周期调用组件的setRules方法绑定验证规则
    
    onReady(() => {
        form.value.setRules(rules1)
    })
    onLoad(async(val) => {
        formData.value = JSON.parse(uni.getStorageSync('storageFormData'))
        formData.value.zo_ex7 = uni.getStorageSync('storagePhone')
        console.log(formData.value)
        let res5: any = await countkilometreApi({
            startPointer: formData.value.zo_ex17,
            endPointer: formData.value.zo_ex18,
            tjdp1: formData.value.zo_tjd_p_1,
            tjdp2: formData.value.zo_tjd_p_2,
            tjdp3: formData.value.zo_tjd_p_3,
            tactics: '0',
        })
        formData.value.zo_ex20 = res5.Kilometre
        formData.value.zo_ex54 = res5.tag
        formData.value.zo_ex46 = res5.toll
        formData.value.zo_ex53 = '0'
        
        let res6: any = await preferentialListApi({})
        res6.data.forEach(item => {
            item.text = item.zb_ex1
            item.value = item.zb_ex1
        })
        zo_ex21Range.value =  res6.data
        await getMoney()
        console.log('formData.value.zo_ex23-22222222')
        let res7: any = await getCouponCodeListApi({
            
        })
        if (res7.code == 200) {
            zo_ex82Range.value = []
            res7.data.forEach(item => {
                if (item.effective == '有效') {
                    item.text = item.zcc_ex1
                    item.value = item.zcc_ex1
                    item.disable = Number(item.zcc_ex8) > Number(formData.value.zo_ex23)
                    zo_ex82Range.value.push(item)
                }
            })
        }
    })
    onMounted(() => {
       
    })
    const zo_ex21Change = (val) => {
        console.log(val)
        if (!val) {
            // 图片置空
            formData.value.imageValue1 = ''
            formData.value.f_id = ''
            // 折扣置空
            formData.value.zo_ex22 = ''
            // 兑换码
            formData.value.zo_ex78 = ''
        } else if (val == '杭州联合银行贵宾权益') {
            // 图片置空
            formData.value.imageValue1 = ''
            formData.value.f_id = ''
        } else if (val == '现（退）役军人（含家属）、三属人员八一折扣优待礼遇') {
            // 兑换码
            formData.value.zo_ex78 = ''
        }
        zo_ex21Range.value.some((item) => {
            if (item.zb_ex1 == val) {
                formData.value.zo_ex22 = item.zb_ex2
                return true;
            }
        })
        getMoney()
    }
    const zo_ex82Change = (val) => {
        console.log(val)
        if (!val) {
            // 兑换码
            formData.value.zo_ex78 = ''
        }
        zo_ex82Range.value.some((item) => {
            if (item.zcc_ex1 == val) {
                formData.value.zo_ex78 = item.zcc_ex2
                return true;
            }
        })
        getMoney()
    }
    const getMoney = async() => {
        isDisabledConfirm.value = true
        let res6: any = await countmoneyApi({
            province: '', //起始地点的省
            city: '', //起始地点市
            Kilometre: formData.value.zo_ex20, //公里数
            discountType: formData.value.zo_ex21, //惠民权益
            toll: formData.value.zo_ex46, //过路费
            qtmoneys: '', //其他费用
            yuyueDate: formData.value.zo_dat1, //预约时间
            roadamt: '', //固定路线
            oxygen: formData.value.zo_ex74, //是否吸氧
            longitude: formData.value.zo_ex17.split(',')[0], //经度
            latitude: formData.value.zo_ex17.split(',')[1], //纬度
            rc: formData.value.zo_ex78, //兑换码
        })
        if (res6.code == 500) {
            uni.showToast({
                title: res6.msg,
                icon: 'error',
                duration: 1500,
                mask: true,
            });
            if (formData.value.zo_ex82 == '') {
                formData.value.zo_ex78 = ''
            }
        } else {
            console.log('formData.value.zo_ex23')
            formData.value.zo_ex23 = res6.money
            formData.value.zo_ex55 = res6.oxy //吸氧费
            formData.value.zo_ex77 = res6.realDeductionMoney //惠民权益实际扣减费用
            formData.value.couponId = res6.couponId //惠民权益id
            formData.value.zo_ex79 = res6.start //起步价
            formData.value.zo_ex80 = res6.base //里程费
            formData.value.zo_ex81 = res6.other //其他费用
        }
        isDisabledConfirm.value = false
    }
    const showPopup1 = async() => {
        // popup1.value.open()
        if (formData.value.zo_ex73 == '否') {
            popup1.value.open()
            // form.value.validate().then(async(res: any) => {
            //     popup1.value.open()
            // }).catch((err: any) =>{
            //     console.log('表单错误信息：', err);
            //     uni.showToast({
            //         title: err[0].errorMessage,
            //         icon: 'error',
            //         duration: 1500,
            //         mask: true,
            //     });
            // })
            
        } else {
            uni.showModal({
                showCancel: true,
                title: '温馨提示',
                content: '是否确认下单？',
                success: async function (res1) {
                    if (res1.confirm) {
                        console.log('用户点击确定');  
                        submit1()
                    } else if (res1.cancel) {
                        console.log('用户点击取消');
                    }
               }
            }); 
        }
    }
    const redirectToTransferOrder = () => {
        uni.redirectTo({
            url: '/pages/transferOrder/transferOrder'
        });
    }
    const jobTime = () => {
        // 晚17点30分至次日早08点30分请致电人工客服：4008897120预约下单。
        let hour = new Date().getHours()
        let minute = new Date().getMinutes()
        if ((hour < 8 || (hour == 8 && minute < 30)) || (hour > 17 || (hour == 17 && minute >= 30))) {
            popup2.value.open()
        } else {
            redirectToTransferOrder()
        }
    }
    const submit1 = () => {
       console.log(form.value)
       console.log(formData.value)
       
       form.value.validate().then(async(res: any) => {
           console.log('表单数据信息：', res);
            // uni.showModal({
            //     showCancel: true,
            //     title: '温馨提示',
            //     content: '您确认下单吗？',
            //     success: async function (res1) {
            //         if (res1.confirm) {
            //             console.log('用户点击确定');  
            //         } else if (res1.cancel) {
            //             console.log('用户点击取消');
            //         }
            //    }
            // });        
            try {
                let res3: any = await getAreaApi({
                    longitude: formData.value.zo_ex17.split(',')[0],
                    latitude: formData.value.zo_ex17.split(',')[1],
                })
                if (res3.code == 200) {
                    formData.value.zo_ex8 = res3.data[0]
                    formData.value.zo_ex9 = res3.data[1]
                    formData.value.zo_ex10 = res3.data[2]
                    formData.value.adcode = res3.data[3]
                } else {
                    uni.showToast({
                         title: res3.msg,
                         icon: 'error',
                         mask: true,
                    });
                    return false;
                }
                // 下单成功后，不可直接支付，订单支付进入待支付状态，需要通过人工后台电话联系确认，方可进行支付
                let res2: any = await appSaveOrderApi({
                     ...formData.value,
                     invitationCode: uni.getStorageSync('invitationCode'),
                })
                if (res2.code == 200) {
                     // uni.showModal({
                     //     showCancel: false,
                     //     title: '温馨提示',
                     //     content: res2.msg, //订单已形成 稍后客服人员会与你联系 请保持电话通畅
                     //     success: function (res3) {
                     //         uni.removeStorageSync('storageFormData')
                     //         uni.redirectTo({
                     //             url: '/pages/transferOrder/transferOrder'
                     //         });
                     //         // uni.switchTab({
                     //         // 	url: '/pages/transferOrder/transferOrder'
                     //         // });
                     //         // if (res3.confirm) {
                     //         // 	console.log('用户点击确定');
                     //         // } else if (res3.cancel) {
                     //         // 	console.log('用户点击取消');
                     //         // }
                     //     }
                     // });
                     
                } else {
                    uni.showToast({
                         title: res2.msg,
                         icon: 'error',
                         mask: true,
                    });
                    return false;
                }
                // wx873059111ae5f1a8   appid
                // 1682180836 商户号
                // 救道（杭州）健康科技有限公司 商户名称
                // 12345678910111213141516171819202  apiv2密钥
                // PUB_KEY_ID_0116821808362024103100298600000110 公钥id
                // 38F042CEBE85DCEDD925A01E2DC2F66FE2C14C3E 证书序列号
                let res1: any = await getWechatMiniParamApi({
                     orderId: res2.data,
                })
                if (res1.code == 200) {
                    uni.requestPayment({
                        provider: 'wxpay',
                        timeStamp: res1.data.timeStamp,
                        nonceStr: res1.data.nonceStr,
                        package: res1.data.packageVal,
                        signType: res1.data.signType,
                        paySign: res1.data.paySign,
                        success: function (res) {
                            console.log('success:' + JSON.stringify(res));
                            uni.removeStorageSync('storageFormData')
                            jobTime()
                            
                        },
                        fail: function (err) {
                            console.log('fail:' + JSON.stringify(err));
                        }
                    });
                } else {
                    uni.showToast({
                         title: res1.msg,
                         icon: 'error',
                         mask: true,
                    });
                    return false;
                }
            } catch (err) {
                uni.showToast({
                     title: '下单异常',
                     icon: 'error',
                     mask: true,
                });
            } finally {
                
            }
        }).catch((err: any) =>{
            console.log('表单错误信息：', err);
            uni.showToast({
                title: err[0].errorMessage,
                icon: 'error',
                duration: 1500,
                mask: true,
            });
        })
    }
    
    
</script>

<style lang="scss" scoped>
    .home {
        background-color: #f2f2f2;
        // height: 100vh;
        overflow: scroll;
        // background: rgba(211, 211, 211, 1);
    }
    :deep(.uni-forms) {
        padding: 0rpx 10rpx 10rpx;
        box-sizing: border-box;
    }
    .box-1 {
        background-color: rgba(255, 255, 255, 1);
        box-sizing: border-box;
        padding: 20rpx;
        border-radius: 20rpx;
        margin: 20rpx 0;
    }
    .money-box {
        text-align: center;
        font-weight: bold;
        .money-span-1 {
            color: rgb(153, 153, 153);
        }
        .money-span-2 {
            color: #000;
        }
    }
    .button-img {
        width: 80rpx;
        height: 40rpx;
        margin-right: 20rpx;
    }
    
    :deep(.uni-section .uni-section-header__content .distraction) {
        font-weight: bold;
    }
    .point-box-disabled-input {
        width: 100%;
    }
    // 禁用状态输入框
    :deep(.point-box-disabled-input .uni-easyinput .is-disabled ) {
        background-color: #fff !important;
        color: #999999 !important;
    }
    .checkbox-class {
        display: flex;
        align-items: center;
        padding: 30rpx 0;
        box-sizing: border-box;
    }
    .dialog-content {
        height: 800rpx;
        overflow: scroll;
        .dialog-text-1 {
            font-weight: bold;
        }
        .dialog-text-2 {
            color: #313131;
            text-indent: 70rpx;
            line-height: 50rpx;
        }
    }
    
    .my-disabled-input-box {
        width: 100%;
        :deep(.uni-easyinput .uni-easyinput) {
            background-color: #fff !important;
            font-weight: bold;
        }
    }
    :deep(.my-disabled-input-box .uni-easyinput .is-disabled ) {
        background-color: #fff !important;
        color: #999999 !important;
    }
    .hkzy {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        color: #c7c1c1
    }
    // 组合框下拉选项
    :deep(.uni-combox) {
        background: #fff;
    }
    :deep(.uni-combox .uni-combox__selector .uni-combox__selector-scroll) {
        max-height: 80vh !important;
    }
    
    .checkbox-box {
        height: 100%; 
        display: flex;
        align-items: center;
    }
    :deep(.my-data-select-1 .uni-select__input-box) {
        width: 300rpx;
    }
    .my-popup-box {
        background: #fff; 
        width: 600rpx; 
        box-sizing: border-box; 
        padding: 0 0 30rpx 0; 
        border-radius: 40rpx;
        .my-popup-box-img {
            background: url(https://jdzy.tianxunwang.com/business/image/jdzy/applet/static/transshipmentInformation/popup-bg-2.png); 
            background-size:100% 100%; 
            width:100%; 
            height: 150rpx; 
            border-radius: 50rpx 50rpx 0 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            .my-popup-box-img-text {
                font-size: 30rpx;
                letter-spacing: 10rpx;
                font-weight: bold;
            }
        }
        .my-popup-box-content {
            font-size: 26rpx; 
            box-sizing: border-box; 
            padding: 30rpx;
            .my-popup-box-content-text-1 {
                padding-bottom: 20rpx;
            }
        }
    }
    .disabled-btn {
        background-color: rgba(41, 121, 255, 0.6) !important;
        color: #fff9f9 !important;
        display: flex;
        justify-content: center;
        align-items: center; 
        width: 100%;
    }
    .default-btn {
        background-color: #2979ff !important;
        color: #fff !important;
        display: flex;
        justify-content: center;
        align-items: center; 
        width: 100%;
    }
</style>
